package com.fxl.majiang.vo;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author fengxinglei
 * @date 2022/8/16 11:28
 * @description TODO
 */
@Data
@NoArgsConstructor
public class ApiResponse<T> {

    private int code;
    private String msg;
    private T data;

    public static <T> ApiResponse<T> success(T data) {
        ApiResponse<T> response = new ApiResponse<>();
        response.setCode(200);
        response.setMsg("成功");
        response.setData(data);
        return response;
    }

    public static <T> ApiResponse<T> error(String msg) {
        ApiResponse<T> response = new ApiResponse<>();
        response.setCode(500);
        response.setMsg(msg);
        return response;
    }

}
